function [pos rss0 n] = optimal(pix, rss, fillvalue, pixnumber, prev,width,height)
    options = optimoptions('fmincon', 'MaxIter', 100); 
    [~, poss] = evalc('fmincon(@(t)(costfunction(t, pix, rss, fillvalue, pixnumber)), prev,[],[],[],[],[40,2,0,0],[60,4,width,height], [], options)');
    pos = poss(3:4);
    rss0 = poss(1);
    n = poss(2);
end